﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Windows.Forms;

namespace Christmas_Card
{
    class Timeline
    {
        private ArrayList eventList;
        

        private Timer clock;
        private int currentTime = 0;

        public Timeline()
        {
            eventList = new ArrayList();
            
            clock = new Timer();
            clock.Interval = 1000;
            clock.Tick += new EventHandler(clock_Tick);

        }

        void clock_Tick(object sender, EventArgs e)
        {
            foreach (EventObj evt in eventList)
            {
                if (evt.beginTime <= currentTime)
                {
                    evt.perform();
                }
            }
            currentTime++;
        }

        public void perform()
        {
            clock.Start();
        }

        public void addEvent(EventObj evt)
        {
            eventList.Add(evt);
        }
    }
}
